I have checked most of the questions on SO, but didn't find my answer.
I'm trying to get a JWT token from a Identity server.
Here's how:
var discoveryDocument = new DiscoveryDocumentRequest
{
Address = "https://admin.blabla.app:5000/",
Policy =
{
RequireHttps = false
}
};
var auth = httpClient.GetDiscoveryDocumentAsync(discoveryDocument).Result;
The error I'm getting is An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.
DiscoveryDocumentRequest
{
"Policy": {
"LoopbackAddresses": [
"localhost",
"127.0.0.1"
],
"Authority": "https://admin.blabla.app:5000",
"AuthorityValidationStrategy": {},
"RequireHttps": false,
"AllowHttpOnLoopback": true,
"ValidateIssuerName": true,
"ValidateEndpoints": true,
"EndpointValidationExcludeList": [],
"AdditionalEndpointBaseAddresses": [],
"RequireKeySet": true
},
"Address": "https://admin.blabla.app:5000/",
"ClientId": null,
"ClientSecret": null,
"ClientAssertion": {
"Type": null,
"Value": null
},
"ClientCredentialStyle": 1,
"AuthorizationHeaderStyle": 0,
"Parameters": [],
"Version": {
"Major": 1,
"Minor": 1,
"Build": -1,
"Revision": -1,
"MajorRevision": -1,
"MinorRevision": -1
},
"Content": null,
"Method": {
"Method": "GET"
},
"RequestUri": null,
"Headers": [
{
"Key": "Accept",
"Value": [
"application/json"
]
}
],
"Properties": {}
}
This code is on a windows service.
Fun fact: Same code works on different windows machines. Why? What might be the problem?
Refer to this sample and please write:
var client = new HttpClient();
var disco = await client.GetDiscoveryDocumentAsync("https://admin.blabla.app:5000/");
if (disco.IsError)
{
Console.WriteLine(disco.Error);
return;
}
please check your URL https://admin.blabla.app:5000/ your error is related to your URL you can test your code by https://demo.identityserver.io/